package com.bawei.rk_01.Adapter

import android.widget.CheckBox
import android.widget.TextView
import com.bawei.base.utils.bean.Car
import com.bawei.rk_01.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class CarAdapter : BaseQuickAdapter<Car,BaseViewHolder>(R.layout.item_car) {
    override fun convert(holder: BaseViewHolder, item: Car) {
        GlideUtils.loadImage(context,item.image,holder.getView(R.id.car_image))
        holder.setText(R.id.car_name,item.storeName)
        holder.setText(R.id.car_type,item.suk)
        holder.setText(R.id.car_money,item.price)
        holder.setText(R.id.sum,item.cartNum.toString())

        //给选择按钮赋值，点击底部进行全选时，rv中的选择按钮需要更新
        holder.getView<CheckBox>(R.id.dx).isChecked = item.isCheck

        //当数量等于1时
        holder.getView<TextView>(R.id.red).isEnabled = item.cartNum != 1

    }
}